<template>
  <div>
    <div class="banner">
      <van-swipe class="my-swipe" :autoplay="3000" :indicator-color="'#fff'">
        <van-swipe-item v-for="image in bannerImg" :key="image">
          <img :src="'https://jingqu.kuxia.top' + image" class="banner_img" />
          <template #indicator="{ active, total }">
            <div class="custom-indicator">{{ active + 1 }}/{{ total }}</div>
          </template>
        </van-swipe-item>
      </van-swipe>
      <div class="return">
        <img src="../assets/go_back.png" alt="" @click="target">
      </div>
    </div>
    <!-- 主要信息 -->
    <div class="massage_box">
      <h2>{{ RaidersData.title }}</h2>
      <div class="Information">
        <img :src="'https://jingqu.kuxia.top' + RaidersData.img" alt="">
        <p>{{ RaidersData.name }}</p>
        <p>{{ RaidersData.create_time }}</p>
      </div>
      <div>{{ RaidersData.introduce }}</div>
    </div>
    <div class="discuss_title">
      <h2>评论</h2>
      <p>全部{{ StrategyData.length }}条</p>
    </div>
    <!-- 评论内容 -->
    <div class="discuss_content" v-for="item in StrategyData" :key="item">
      <!-- 顶部内容 -->
      <div class="discuss_top">
        <img :src="'https://jingqu.kuxia.top' + item.img" alt="">
        <div class="discuss_top_box">
          <div class="discuss_top_name">
            <p>{{ item.name }}</p>
            <p>{{ item.create_time }}</p>
          </div>
          <div class="Clock">
            <p>评分</p> <van-rate v-model="item.score" color="#FDB246" readonly/>
          </div><!--打卡-->
        </div>
      </div>
      <div class="discuss_content_box">{{ item.content }}</div>
      <div class="discuss_img">
        <img :src="'https://jingqu.kuxia.top' + item.img" alt="">
      </div>
      <div class="discuss_bottom">
        浏览量{{ item.number == null ? 0 : item.number }}
        <img src="../assets/arrows.png" alt="">
      </div>
    </div>
    <!-- 暂无提示 -->
    <div class="not_yet">
      没有更多了…
    </div>
    <!-- 底部导航栏 -->
    <div class="Bottom_navigation">
      <!-- 添加评论 -->
      <div class="add_discuss" @click="targetPage(RaidersData.id)">
        添加评论…
      </div>
      <div class="Bottom_navigation_option">
        <img src="../assets/likeyou.png" alt="">
        <img src="../assets/star-border.png" alt="">
        <img src="../assets/comment.png" alt="">
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { useRoute } from 'vue-router';//引入路由
import { useRouter } from 'vue-router';
import { Introcom, StrategyIndex } from '../api/scenic.js';//引入接口
const RaidersData = ref(null);//当前点击的数据
const StrategyData = ref(null);//评论列表接口
const bannerImg = ref([]);//轮播图
const route = useRoute();//获取到传参
console.log(route.query.id);
function target() {
  router.push({
    path: '/strategy',
  });
}
// 攻略列表
StrategyIndex({ scenic_id: 2 }).then(function (res) {
  for (let i in res.data) {
    if (res.data[i].id == route.query.id) {
      // 获取到点击进入的数据
      RaidersData.value = res.data[i];
      console.log(RaidersData);
      // 获取到数据中的轮播图
      bannerImg.value = res.data[i].bannar.split(',');
    }
  }
});

// 攻略评论列表
Introcom({ intri_id: route.query.id }).then(function (res) {
  console.log(res);
  StrategyData.value = res.data === null ? [] : res.data;
  console.log(StrategyData);

});
// 跳转传参
function targetPage(id) {
  router.push({
    path: '/issuance',
    query: {
      id: id
    }
  });
}
const router = useRouter();
</script>

<style scoped>
.banner {
  position: relative;
}

.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  height: 150px;
  text-align: center;
  position: relative;
  background-color: #fff;
}

.banner_img {
  width: 100%;
  height: 100%;
}

.return {
  width: 40px;
  height: 40px;
  position: absolute;
  overflow: hidden;
  margin: 5px;
  z-index: 5;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.return img {
  width: 100%;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.5);
}

/* 整体用户信息 */
.massage_box {
  padding: 2%;
}

.Information {
  min-width: 50%;
  max-width: 80%;
  display: flex;
  margin: 5px 0px;
  align-items: center;
}

.massage_box h2 {
  font-weight: 800;
}

.Information p {
  margin: 0px 5px;
}


.Information img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
}

/* 评论顶部提示 */
.discuss_title {
  width: 100%;
  height: 60px;
  padding: 0% 1%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

/* 评论 */
.discuss_content {
  width: 100%;
  padding: 2%;
  margin-bottom: 5px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

/* 顶部头像与名称 */
.discuss_top {
  width: 100%;
  display: flex;
}

.discuss_top img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
}

.discuss_top_box {
  width: 80%;
}

/* 顶部名称 */
.discuss_top_name {
  width: 100%;
  display: flex;
  justify-content: space-between;
}

.discuss_top_name p {
  margin-left: 5px;
}

/* 打卡 */
.Clock {
  width: 100%;
  display: flex;
}

.Clock p {
  margin-left: 5px;
}

/* 评论内容 */
.discuss_content_box {
  padding: 0px 5px 5px 5px;
}

/* 评论图片 */
.discuss_img {
  width: 100%;
}

.discuss_img img {
  width: 30%;
}

.discuss_bottom {
  padding: 0% 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.discuss_bottom img {
  width: 10px;
}

/* 底部的导航栏 */
.add_discuss {
  width: 50%;
  height: 30px;
  color: black;
  text-align: center;
  border-radius: 15px;
  line-height: 30px;
  background-color: #E5E5E5;
}

.Bottom_navigation_option {
  width: 40%;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.Bottom_navigation_option img {
  width: 30px;
}
</style>